<template>
  <div class="page">
    <div class="top">
      <div class="list-bar">
        <div v-for="(item,index) in barList" :key="index" class="item-bar">
          <div :class="{'curbg':curIndex==index}" @click="clickTab(item.name,index)">{{item.name}}</div>
        </div>
      </div>
      <div class="midd">
        <div class="item">
          <img src="../assets/img/xy28.png">
          <div class="right">
            <p>
              最新：
              <span>1928394343</span> 期
            </p>
            <div>picker</div>
          </div>
        </div>
        <div class="item">
          下一期:
          <Count
            v-on:end_callback="countDownE_cb()"
            :currentTime="countObj.realTime"
            :startTime="countObj.realTime"
            :endTime="countObj.endTime"
            dayTxt="天"
            :hourTxt="'时'"
            :minutesTxt="'分'"
            :secondsTxt="'秒'"
          ></Count>
        </div>
        <div class="item t">
          <span>1</span> +
          <span>1</span> +
          <span>1</span> =
          <span>9</span>
          <i></i>
          <span class="h">大</span>
          <span class="h">双</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import api from "../api/index.js";
import Count from "../components/count";
import axios from "axios";
import { Toast } from "mint-ui";
import InfiniteLoading from "vue-infinite-loading";

export default {
  components: {
    Count,
    InfiniteLoading
  },
  data() {
    return {
      barList: [
        { name: "幸运28", id: 0 },
        { name: "北京赛车", id: 1 },
        { name: "金边五分彩", id: 2 },
        { name: "北京28", id: 3 },
        { name: "幸运飞艇", id: 4 },
        { name: "重庆时时彩", id: 5 },
        { name: "加拿大28", id: 6 },
        { name: "极速赛马", id: 7 },
        { name: "激素赛车", id: 8 }
      ],
      countObj: {
        realTime: new Date().getTime(),
        endTime: new Date().getTime() + 20000 * 15
      },
      curIndex: 0
    };
  },
  created() {
    // this.cityListReq();
    //   this.cityReq()
    //   this.curIndex=sessionStorage.getItem('curIndex');
    //   this.curCityPass = this.$route.query.name;
    //   console.log( this.curIndex)
  },
  methods: {
    cityReq() {
      let that = this;
      let cip = returnCitySN["cip"];
      if (cip) {
        let params = {
          ip: cip
        };
        api.cityApi(params).then(res => {
          // console.log(res)
          this.cityListReq();
          if ((res.msgCode = "000")) {
            if (res.data) {
              this.curCity = res.data;
              if (this.curCity) {
                this.gpsCity = this.curCity;
                this.cityshow = true;
              } else {
                this.cityshow = false;
              }
            }
          } else {
            Toast({
              message: res.msg,
              position: "middle",
              duration: 5000
            });
          }
        });
      }
    },
    cityListReq() {
      let obj = {};
      api.cityListApi(obj).then(res => {
        console.log(res);
        if ((res.msgCode = "000")) {
          this.ktList = res.data.list;
          this.ktList.map((item, index) => {
            if (this.curCityPass == item.mobileName) {
              this.curIndex = index;
            }
          });
        } else {
          Toast({
            message: res.msg,
            position: "middle",
            duration: 5000
          });
        }
      });
    },
    clickTab(name, index) {
      this.curIndex = index;
    },
    goHome(id, name, index) {
      localStorage.setItem("siteId", id);
      localStorage.setItem("siteName", name);
      sessionStorage.setItem("curIndex", index);
      // this.clickRed = false;
      // this.$router.push({
      //   path: '/',
      //   query: {
      //     cityName: name
      //   }
      // })
      this.$router.go(-1);
    },
    countDownE_cb(e) {}
  }
};
</script>

<style scoped>
.page {
  background-color: #fff;
}
.top {
  background-color: #f6f5f5;
  width: 96%;
  margin-left: 2%;
  margin-top: 6px;
  min-height: 140px;
  border: 1px solid #eee;
}
.top .list-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  border-bottom: 1px solid #eee;
}
.list-bar .item-bar {
  width: 33.33%;
}
.item-bar div {
  height: 38px;
  line-height: 38px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #333;
  text-decoration: none;
  background-color: #fff;
  border-right: 1px solid #eee;
}
.item-bar .curbg {
  background-color: #2196f3;
  color: #fff;
}
.midd {
  display: flex;
  flex-wrap: wrap;
  padding: 4px 4px 0 4px;
}
.midd .item {
  height: 68px;
  min-width: 350px;
  border: 1px solid #eee;
  background-color: #fff;
  text-align: center;
  flex: 1;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.midd .item img {
  width: 60px;
}
.midd .item .right {
  display: inline;
  padding: 0 10px;
}
.midd .item .right p {
  font-size: 16px;
  color: #333;
  line-height: 36px;
  margin: 0;
  padding: 0;
}
.midd .item .right p span {
  font-family: Tahoma;
  color: #e63442;
}

.midd .item.t span {
  display: inline-block;
  width: 38px;
  height: 38px;
  text-align: center;
  line-height: 38px;
  font-size: 18px;
  color: #fff;
  font-weight: bold;
  background-color: #13b5b1;
  border-radius: 2px;
  margin: 0 4px;
}
.midd .item.t {
  line-height: 38px;
  font-size: 18px;
  color: #717171;
  /* font-weight: bold; */
}
.midd .item.t i{
  height: 38px;
  width: 1px;
  background-color: #e8e8e8;
  margin: 0 10px;
}

.midd .item.t .h{
    background-color: #e60012;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 14px;
    line-height: 28px;
    text-align: center;
    font-size: 14px;
    margin: 0 7px;

}
</style>
